import { ajaxService } from '@/utils/request';
import { FlowParams } from './flow-type';

/**
 * 搜索审批列表
 * @param data
 * @returns
 */
export function postBasisFlowSearch(data: FlowParams) {
  return ajaxService({
    url: 'http://192.168.0.120:19004/basis/flow/search',
    method: 'post',
    data,
  });
}
/**
 * 编辑审批流程
 * @param data
 * @returns
 */
export function putBasisFlow(data: any) {
  return ajaxService({
    url: 'http://192.168.0.120:19004/basis/flow',
    method: 'put',
    data,
    noToken: false,
    // baseURL,
  });
}
/**
 * 启用/关闭审批流程
 * @param data
 * @returns
 */
export function putBasisFlowSwitchStatus(data: { id: number }) {
  return ajaxService({
    url: 'http://192.168.0.120:19004/basis/flow/switchStatus',
    method: 'put',
    data,
    noToken: false,
    // baseURL,
  });
}
/**
 * 删除审批流程
 * @param params
 * @returns
 */
export function delBasisFlow(params: { id: number }) {
  return ajaxService({
    url: 'http://192.168.0.120:19004/basis/flow',
    method: 'delete',
    params,
    noToken: false,
    // baseURL,
  });
}
interface BasisFlowSubmitReview {
  type: number; // 类型1需求2合同3供应商审核4供应商认证5发票
  typeId: number; // 需求id
  templateId: number; // 模板id
}
/**
 * 提交评审
 * @param data
 * @returns
 */
export function putBasisFlowSubmitReview(data: BasisFlowSubmitReview) {
  return ajaxService({
    url: 'http://192.168.0.120:19004/basis/flow/submitReview',
    method: 'put',
    data,
    noToken: false,
    // baseURL,
  });
}
interface BasisFlowAudit {
  type: number; // 类型1需求2合同3供应商审核4供应商认证5发票
  typeId: number; // 流程id
  isPass: number; // 是否通过1.通过 2.不通过
  comment: string; // 评价
}
/**
 * 评审
 * @param data
 * @returns
 */
export function postBasisFlowAudit(data: BasisFlowAudit) {
  return ajaxService({
    url: 'http://192.168.0.120:19004/basis/flow/audit',
    method: 'post',
    data,
  });
}
